home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8354 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: C compiling question
  5. Date: 3 Mar 1996 15:57:07 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4hcfgj$1qn@sparcserver.lrz-muenchen.de>
  9. References: <3138D53F.41C6@mashie.ece.jhu.edu>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. Chenyang Xu <chenyang@mashie.ece.jhu.edu> writes:
  13.  
  14. >Hi, there,
  15.  
  16. >===foo1.c===
  17. >#include "stdio.h"
  18. >#include "math.h"
  19.  
  20. >void print_msg1()
  21. >{
  22. >  float x = 1.0;
  23. >  float y;
  24. >  y = exp(x);
  25. >  printf("foo1.c\n");  
  26. >  printf("%f\n", y);  
  27.  
  28. >  return;
  29. >}
  30.  
  31. >===foo2.c===
  32. >void print_msg2()
  33. >{
  34. >  printf("foo2.c\n");  
  35. >  print_msg1();
  36. >  return;
  37. >}
  38.  
  39. >My question is how the print_msg2() knows print_msg1() and carrys out
  40. >the result
  41. > without causing a compiling or linking error or warning, 
  42.  
  43. Since there is no declaration for print_msg1() in foo2.c, the compiler
  44. _must_ assume that print_msg1() is a function taking no parameters 
  45. and returning int. It must compile your program. It _should_ print
  46. a diagnostic telling you that it has made the abovementioned assumption.
  47.  
  48. You are lucky that there is no difference in the calling sequence of
  49. a function returning an int and a function _not_ returning anything
  50. in your implementation. So, don't try this "trick" in an implementation
  51. with different calling schemes.
  52.  
  53. Kurt
  54. --
  55. | Kurt Watzka                             Phone : +49-89-2180-6254
  56. | watzka@stat.uni-muenchen.de
  57. | ua302aa@sunmail.lrz-muenchen.de
  58.